package com.service;

import java.sql.Date;
import java.util.List;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.dao.BankDao;
import com.model.Bank;
import com.model.BankDeposit;
import com.model.BankWithdraw;
import com.model.Branch;

@Service("bankService")
@Transactional
public class BankServiceImpl implements BankService{
	
	@Autowired
	private BankDao bankDao;
	
	
	public void add(String branch,Bank bank) {
		bankDao.add(branch,bank);		
	}

	public List<Bank> getAll() {
		return bankDao.getAll();
	}

	public Bank get(Integer id) {
		return bankDao.get(id);
	}

	public void delete(Integer id) {
		bankDao.delete(id);

	}

	public List<Bank> getByDate(Date from,Date to)
	{
		return bankDao.getByDate(from, to);
	}


	public List<Bank> getAll(int page) {
		return bankDao.getAll(page);

	}

	public int getNoOfRecords() {
		return bankDao.getNoOfRecords();
	}

	@Override
	public void addDeposit(Integer bankId, BankDeposit deposit) {
		bankDao.addDeposit(bankId, deposit);
		
	}

	@SuppressWarnings("rawtypes")
	@Override
	public List getBankName() {
		return bankDao.getBankName();
	}

	@Override
	public void addWithdraw(Integer bankId, BankWithdraw withdraw) {
		bankDao.addWithdraw(bankId, withdraw);
		
	}

	@Override
	public List<Bank> getAllForUser(String name) {
		return bankDao.getAllForUser(name);
	}

	@Override
	public List<Bank> getAllForAdmin() {
		return bankDao.getAllForAdmin();
	}
	
}
